﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ElementImplementForm.aspx.cs"
    Inherits="FantastPlatform.Decision.UI.ElementImplementForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var eif = new FantastPlatform.UI.ElementImplementForm({
            renderTo: 'eif_div',
            Id: '<%=GetId() %>',
            FlowId: '<%=GetFlowId() %>',
            Level: '<%=GetLevel() %>',
            url: '../Service/FlowElementViewService.aspx?Action=AddElementImplement&flowId=' + '<%=GetFlowId() %>' + '&level=' + '<%=GetLevel() %>',
            tbar: [{
                text: '保存',
                iconCls: 'save',
                id: 'saveNotice',
                handler: function () {
                    submitElementImplementJson(eif, currtWind, eig, fip.FlowForm.form.getValues().Id);

                }
            }, '-', {
                text: '重置',
                iconCls: 'cancel',
                id: 'cancelNotice',
                handler: function () { eif.form.reset(); }
            }]
        });
        function submitElementImplementJson(form, sender, grid, flowId) {
            if (form.form.isValid()) {
                var myMask = new Ext.LoadMask(form.getEl(), {
                    msg: "正在保存数据,请稍候...."
                });
                var dataStr = Ext.util.JSON.encode(form.form.getValues());              
                myMask.show();
                var url = form.url;               
                Ext.Ajax.request({
                    method: 'post',
                    url: url,
                    params: { data: dataStr },
                    success: onSuccess,
                    failure: onFailure
                });
                function onSuccess(request, options) {
                    // 服务器返回json形式的结果
                    myMask.hide();
                    var reText = request.responseText;
                    var reTextObj = Ext.util.JSON.decode(reText);
                    if (eval(reTextObj.success)) {
                        showMessage('操作成功', reTextObj.message);
                        if (grid) {                            
                            grid.store.removeAll();
                            grid.store.load({ params: { flowId: flowId, start: 0, limit: grid.paperBar.getPageNumber(), dir: '', sort: ''} });
                        }
                        if (sender)
                            sender.close();                       
                    } else {
                        showErrorMessage('操作失败', reTextObj.message, '');
                    }
                }
                function onFailure(request, options) {
                    myMask.hide();
                    showErrorMessage('操作失败', request.responseText, '');
                }
            }
        }
    </script>
</head>
<body>
    <div id="eif_div">
    </div>
</body>
</html>
